]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
messageTray: Close the notification on Escape
authorStéphane Démurget <stephane.demurget@free.fr>
Thu, 8 Nov 2012 14:38:57 +0000 (15:38 +0100)
committerStéphane Démurget <stephane.demurget@free.fr>
Thu, 8 Nov 2012 20:19:52 +0000 (21:19 +0100)
Now that the notifications can be focused with the keyboard, it's
important we can close the active one also this way.

https://bugzilla.gnome.org/show_bug.cgi?id=652082

js/ui/messageTray.js

index 2f714b0b4aa225ea627ca77878ba25ce2896b807..6a2e43005dd33a72069abcad1e002082e54eee6c 100644 (file)
@@ -1394,6 +1394,8 @@ const MessageTray = new Lang.Class({
                                                    y_expand: true,
                                                    x_expand: true,
                                                    layout_manager: new Clutter.BinLayout() });
+        this._notificationWidget.connect('key-release-event', Lang.bind(this, this._onNotificationKeyRelease));
+
         this.actor.add_actor(this._notificationWidget);
 
         this._notificationBin = new St.Bin({ y_expand: true });
@@ -1443,7 +1445,7 @@ const MessageTray = new Lang.Class({
 
         this._closeButton = makeCloseButton();
         this._closeButton.hide();
-        this._closeButton.connect('clicked', Lang.bind(this, this._onCloseClicked));
+        this._closeButton.connect('clicked', Lang.bind(this, this._closeNotification));
         this._notificationWidget.add_actor(this._closeButton);
 
         this._idleMonitorBecameActiveId = 0;
@@ -1598,7 +1600,19 @@ const MessageTray = new Lang.Class({
         return false;
     },
 
-    _onCloseClicked: function() {
+    _onNotificationKeyRelease: function(actor, event) {
+        let ignoredModifiers = global.display.get_ignored_modifier_mask();
+        let modifierState = event.get_state() & ~ignoredModifiers;
+
+        if (event.get_key_symbol() == Clutter.KEY_Escape && modifierState == 0) {
+            this._closeNotification();
+            return true;
+        }
+
+        return false;
+    },
+
+    _closeNotification: function() {
         if (this._notificationState == State.SHOWN) {
             this._closeButton.hide();
             this._notificationClosed = true;